#ifndef __NULL_ANIMATION_H__
#define __NULL_ANIMATION_H__

//#include "TextureManagerEx.h"
#include "LayerManagerEx.h"

typedef void(*ANICALLBACK)(void * pt);

#define NONE        0x0
#define EASEIN      0x1
#define EASEOUT     0x2
#define ALIGN_RIGHT 0x4
#define ALIGN_LEFT  0x8
#define ALIGN_DOWN  0x10
#define ALIGN_UP    0x20
#define MIRROR      0x40
#define LOOP        0xFFFFFFFF

typedef struct TagGroupUnit
{
    int        nId;
    int        nOffset1;
    int        nOffset2;
} GROUPUNIT;

class GrafixObjectStack;
class cMoveAction;
class cFlashAction;
class cStretchAction;

class cBaseAnimation
{
public:
    cBaseAnimation();
    cBaseAnimation(GrafixObjectStack * pWs, int x, int y);
    virtual ~cBaseAnimation();
    virtual int SetAnimationParam(int param1 = 0, int param2 = 0, int param3 = 0, int param4 = 0);
    virtual int UpdateAnimation();
    virtual int Reset();
    virtual int ForceRender();

    virtual int OnMouseMove(int x, int y);
    virtual int OnMouseDown(int x, int y);
    virtual int OnMouseUp(int x, int y);
    virtual int OnKeyDown(unsigned int param1);
    virtual int OnKeyUp(unsigned int param1);

    int Start();
    int Stop();
    int Destroy();

    int AutoSleep(int counter);
    int AutoSleep0(int counter);

    bool            m_bActive;
    bool            m_bEvent;
    int             m_nRepeat;
    int             m_nAnimationId;

    LayerManagerEX* m_cLayerManager;
    GrafixObjectStack*    m_pWs;

    ANICALLBACK     m_fpAniCallBack;
    void *          m_pAniClass;

    int             m_nCounter;
    int             m_nFrameCounter;
    int             m_nLastState;

private:
    int             m_nLayerID;

};



class cMoveAction : public cBaseAnimation
{
public:
    cMoveAction(int SrcX, int SrcY, int DstX, int DstY,
                GrafixObjectStack * pWs, LayerManagerEX * pLM,
                int * pGroup, int num, int style, int BeginFrame, int duration,
                ANICALLBACK fpAnime=0, void * pAnime=0, int gid=0);

    cMoveAction(int OffsetX, int OffsetY,
                GrafixObjectStack * pWs, LayerManagerEX * pLM,
                int * pGroup, int num, int style, int BeginFrame, int duration,
                ANICALLBACK fpAnime=0, void * pAnime=0, int gid=0);

    ~cMoveAction();

    int OnFinish();

    int SetAnimationParam(int param1, int param2, int param3, int param4);

    int UpdateAnimation();
    int Reset();

private:
    LayerManagerEX*     m_pLM;
    GROUPUNIT *         m_pGroup;
    int                 m_nLayerNum;
    int                 m_nHVmode;
    int                 m_nStyle;
    int                 m_nDuration;
    int                 m_nCurrX;
    int                 m_nCurrY;
    int                 m_nX1;
    int                 m_nX2;
    int                 m_nY1;
    int                 m_nY2;
    int                 m_nDX;
    int                 m_nDY;
    int                 m_nFinish;
    int                 m_nBeginFrame;
    int                 m_nElapsedTime;
    int                 m_nGid;

};


class cFlashAction : public cBaseAnimation
{
public:

    cFlashAction(int value1, int value2,
                 GrafixObjectStack * pWs, LayerManagerEX * pLM,
                 int * pGroup, int num, int style, int times, int BeginFrame, int duration,
                 ANICALLBACK fpAnime=0, void * pAnime=0, int gid=0);

    ~cFlashAction();

    int SetAnimationParam(int param1, int param2, int param3, int param4);

    int UpdateAnimation();
    int Reset();
    int OnFinish();

private:
    LayerManagerEX* m_pLM;
    GROUPUNIT *     m_pGroup;
    int             m_nValue1;
    int             m_nValue2;
    int             m_nCurrent;
    int             m_nStyle;
    int             m_nLayerNum;
    int             m_nLayerID;
    int             m_nDirection;
    int             m_nDuration;
    int             m_nBeginFrame;
    int             m_nElapsedTime;
    int             m_nGid;
};

class cStretchAction : public cBaseAnimation
{
public:

    cStretchAction(int SrcW, int SrcH, int DstW, int DstH,
                     GrafixObjectStack * pWs, LayerManagerEX * pLM,
                     int * pGroup, int num, int style, int times, int BeginFrame, int duration,
                     ANICALLBACK fpAnime=0, void * pAnime=0, int gid=0);

    ~cStretchAction();

    int SetAnimationParam(int param1, int param2, int param3, int param4);
    int ResizeLayer(int width, int height, int style=0);
    int UpdateAnimation();
    int Reset();
    int OnFinish();

private:
    LayerManagerEX* m_pLM;
    GROUPUNIT *     m_pGroup;
    int             m_nCurrX;
    int             m_nCurrY;
    int             m_nX1;
    int             m_nX2;
    int             m_nY1;
    int             m_nY2;
    int             m_nDX;
    int             m_nDY;
    int             m_nCurrent;
    int             m_nStyle;
    int             m_nLayerNum;
    int             m_nLayerID;
    int             m_nDirection;
    int             m_nDuration;
    int             m_nHVmode;
    int             m_nBeginFrame;
    int             m_nElapsedTime;
    int             m_nGid;
};



#endif

